package com.lb.jwitter.action;


import java.util.Collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import java.util.Map; 
import org.springframework.test.context.ContextConfiguration; 
import com.lb.jwitter.service.TblQuyenChiTietService; 
import com.lb.jwitter.service.TblTaiKhoan; 
import com.opensymphony.xwork2.ActionContext; 
import com.lb.jwitter.util.ApplicationContextProvider; 
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.opensymphony.xwork2.Action; 
import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhiMonHoc;
import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhiMonHocService;
import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhi;
import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhiService;

import com.lb.jwitter.service.TblQLDTTXAMonHoc;
import com.lb.jwitter.service.TblQLDTTXAMonHocService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblQLDTTXAHocVienHocPhitblQLDTTXAHocVienHocPhiMonHocEditFormAction{
    private int id; 
    public void setId(int id) {
       this.id = id;
 }

    public int getId() {
       return id;
 }

    private TblQLDTTXAHocVienHocPhiMonHoc tblQLDTTXAHocVienHocPhiMonHoc; 
    public TblQLDTTXAHocVienHocPhiMonHoc getTblQLDTTXAHocVienHocPhiMonHoc() { 
        return tblQLDTTXAHocVienHocPhiMonHoc; 
    } 
    private TblQLDTTXAHocVienHocPhi tblQLDTTXAHocVienHocPhi; 
    public TblQLDTTXAHocVienHocPhi getTblQLDTTXAHocVienHocPhi() { 
        return tblQLDTTXAHocVienHocPhi; 
    } 
    private Collection<TblQLDTTXAHocVienHocPhiMonHoc> tblQLDTTXAHocVienHocPhiMonHocs; 
    public Collection<TblQLDTTXAHocVienHocPhiMonHoc>  getTblQLDTTXAHocVienHocPhiMonHocs() {
         return tblQLDTTXAHocVienHocPhiMonHocs; 
      } 

    private TblQLDTTXAHocVienHocPhiMonHocService tblQLDTTXAHocVienHocPhiMonHocService; 

    private Collection<TblQLDTTXAHocVienHocPhi> tblQLDTTXAHocVienHocPhis; 
    public Collection<TblQLDTTXAHocVienHocPhi>  getTblQLDTTXAHocVienHocPhis(){ 
              return tblQLDTTXAHocVienHocPhis; 
     } 

    private TblQLDTTXAHocVienHocPhiService tblQLDTTXAHocVienHocPhiService; 

    private Collection<TblQLDTTXAMonHoc> tblQLDTTXAMonHocs; 
    public Collection<TblQLDTTXAMonHoc>  getTblQLDTTXAMonHocs(){ 
              return tblQLDTTXAMonHocs; 
     } 

    private TblQLDTTXAMonHocService tblQLDTTXAMonHocService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
    public String execute() throws Exception 
   { 
    try{ 
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_HocVienHocPhi_MonHoc", "sua")){ 
        return "noprivilege"; 
    }        tblQLDTTXAHocVienHocPhiMonHocService = (TblQLDTTXAHocVienHocPhiMonHocService) context.getBean("tbl_QLDTTXA_HocVienHocPhi_MonHocClient"); 
        tblQLDTTXAHocVienHocPhiService = (TblQLDTTXAHocVienHocPhiService) context.getBean("tbl_QLDTTXA_HocVien_HocPhiClient"); 

        tblQLDTTXAMonHocService = (TblQLDTTXAMonHocService) context.getBean("tbl_QLDTTXA_MonHocClient"); 

        tblQLDTTXAHocVienHocPhiMonHoc = tblQLDTTXAHocVienHocPhiMonHocService.gettblQLDTTXAHocVienHocPhiMonHoc(new Long(id)); 
        tblQLDTTXAHocVienHocPhi = tblQLDTTXAHocVienHocPhiMonHoc.getHocVienHocPhiId(); 
        tblQLDTTXAMonHocs = tblQLDTTXAMonHocService.findAlltblQLDTTXAMonHoc(0, 0);

        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi EditForm tbl_QLDTTXA_HocVienHocPhi_MonHoc Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
